package com.alibaba.nacos.core.remote.grpc;

import com.alibaba.nacos.api.naming.remote.request.InstanceRequest;
import com.alibaba.nacos.api.remote.request.ConnectionSetupRequest;
import com.alibaba.nacos.api.remote.request.ServerCheckRequest;
import com.alibaba.nacos.common.remote.PayloadRegistry;
import com.alibaba.nacos.common.utils.JacksonUtils;

public class RequestTestUtils {

    static {
        PayloadRegistry.init();
    }

    public static InstanceRequest getInstanceRequest() {
        String text = "{\"headers\":{\"app\":\"unknown\"},\"namespace\":\"public\",\"serviceName\":\"service-provider\",\"groupName\":\"DEFAULT_GROUP\",\"type\":\"registerInstance\"," +
                "\"instance\":{\"ip\":\"172.17.128.1\",\"port\":18082,\"weight\":1.0,\"healthy\":true,\"enabled\":true,\"ephemeral\":true,\"clusterName\":\"\"," +
                "\"metadata\":{\"IPv6\":\"[240e:39a:388:bbe0:ebcc:e23f:2fb0:f9ab]\",\"preserved.register.source\":\"SPRING_CLOUD\"},\"ipDeleteTimeout\":30000,\"instanceHeartBeatTimeOut\":15000," +
                "\"instanceHeartBeatInterval\":5000},\"module\":\"naming\"}";

        return JacksonUtils.toObj(text, InstanceRequest.class);
    }

    public static ServerCheckRequest getServerCheckRequest() {
        String text = "{\"headers\":{},\"module\":\"internal\"}";
        return JacksonUtils.toObj(text, ServerCheckRequest.class);
    }

    public static ConnectionSetupRequest getConnectionSetupRequest() {
        String text = "{\"headers\":{},\"clientVersion\":\"Nacos-Java-Client:v2.2.0\",\"labels\":{\"module\":\"naming\",\"source\":\"sdk\"},\"module\":\"internal\"}";
        return JacksonUtils.toObj(text, ConnectionSetupRequest.class);
    }
}
